﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Model;
using BLL;
using Common;

namespace Web
{
    public partial class AdminManagerExit_UI : Form
    {
        public AdminManagerExit_UI()
        {
            InitializeComponent();
        }
        Admin_BLL abb = new Admin_BLL();
        Com com = new Com();
        public string loginid;
        public AdminManager_UI manager = null;
        private void button1_Click(object sender, EventArgs e)
        {
            Admin admin = new Admin();
            admin.LoginId = textBox1.Text.Trim();
            admin.LoginPwd = textBox2.Text.Trim();
            admin.LoginRemark = textBox3.Text.Trim();
            admin.LoginType = comboBox1.SelectedItem.ToString();
            if (abb.ExitAdmin(admin) > 0)
            {
                MessageBox.Show("修改信息成功！");
                //图书类型信息的绑定
                manager.btnSelect_Click(null, null);
                //自动找到刚刚添加成功的新行，并选中
                com.AutoFindRow(textBox1.Text.Trim(), this.manager.dataGridView1);
                this.Close();
            }
            else
            {
                MessageBox.Show("修改信息失败！");
            }
        }

        private void AdminManagerExit_UI_Load(object sender, EventArgs e)
        {
            List<Admin> admins = abb.selectAdmin(loginid);
            textBox1.Text = admins[0].LoginId;
            textBox2.Text = admins[0].LoginPwd;
            comboBox1.SelectedItem = admins[0].LoginType;
            textBox3.Text = admins[0].LoginRemark;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
